/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.myapp.struts.reports;

//~--- non-JDK imports --------------------------------------------------------
import net.sf.jasperreports.engine.*;

//~--- JDK imports ------------------------------------------------------------

import java.util.*;

import javax.servlet.http.*;

public class PurchaseRepLocWise extends HttpServlet implements JRDataSource {

    private static final long serialVersionUID = 1L;
    int data = 0;
    private int index = -1;
    public int c1 = 0,
            c2 = 0,
            c3 = 0,
            c4 = 0,
            c5 = 0,
            c6 = 0,
            c7 = 0,
            c8 = 0;
    String rd = "",
            vd = "";
    Vector v1 = new Vector();
    Vector v2 = new Vector();
    Vector v3 = new Vector();
    Vector v4 = new Vector();
    Vector v5 = new Vector();
    Vector v6 = new Vector();
    Vector v7 = new Vector();
    Vector v8 = new Vector();

    public PurchaseRepLocWise(int data, Vector v1, Vector v2, Vector v3, Vector v4, Vector v5, Vector v6, Vector v7,
            Vector v8) {
        this.data = data;
        this.v1 = v1;
        this.v2 = v2;
        this.v3 = v3;
        this.v4 = v4;
        this.v5 = v5;
        this.v6 = v6;
        this.v7 = v7;
        this.v8 = v8;
    }

    public boolean next() throws JRException {
        index++;

        return (index < data);
    }

    /**
     *
     */
    public Object getFieldValue(JRField field) throws JRException {
        System.out.println("Entered");

        Object value = null;
        String sna = "",
                fna = "",
                date = "",
                gp = "",
                sql = "";
        int marks = 0;
        double phone = 0.0,
                bank = 0.0;
        HttpServletResponse response = null;
        HttpServletRequest request = null;
        String fieldName = field.getName();

        try {
            if ("purchase_iname".equals(fieldName)) {
                System.out.println("iname------------");
                value = v1.elementAt(c1);
                c1++;
            } else if ("purchase_sname".equals(fieldName)) {
                value = v2.elementAt(c2);
                c2++;
            } else if ("purchase_qty".equals(fieldName)) {
                value = v3.elementAt(c3);
                c3++;
            } else if ("purchase_rate".equals(fieldName)) {
                value = v4.elementAt(c4);
                c4++;
            } else if ("purchase_value".equals(fieldName)) {
                value = v5.elementAt(c5);
                c5++;
            } else if ("purchase_pdate".equals(fieldName)) {
                value = v6.elementAt(c6);
                c6++;
            } else if ("purchase_location".equals(fieldName)) {
                value = v7.elementAt(c7);
                c7++;
            } else if ("items_uom".equals(fieldName)) {
                value = v8.elementAt(c8);
                c8++;
            }
        } catch (Exception p) {
        }

        return value;
    }
}
